package com.woniuxy.controller;

import com.woniuxy.entity.PageEntity;
import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacManagerService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: ideaAdmin
 * TODO: 管理用户的控制器
 * Date: 2022/2/21:13:05
 * Description:
 */
@RestController
@RequestMapping("/rbacManager")
@RequiresAuthentication//设置访问这个类的所有方法都需要登入权限
public class RbacManagerController {

    @Autowired
    RbacManagerService rbacManagerService;

    //@RequestMapping("/findAll/{currentPage}/{pageSize}")
    @RequestMapping("/findAll")
    @RequiresRoles({"超级管理员","普通管理员",})
    @RequiresPermissions({"增加角色","查看角色","删除角色"})
   // public ResponseEntity findAll(@PathVariable("currentPage") Integer currentPage,@PathVariable("pageSize") Integer pageSize){
    public ResponseEntity findAll(@RequestBody PageEntity pageSize){

        return  rbacManagerService.findAll(pageSize);
    }
    @DeleteMapping("/delOne/{id}")
    public ResponseEntity delOne(@PathVariable Integer id){
        return rbacManagerService.delOne(id);
    }

    @PostMapping("/addOne")
    public ResponseEntity addOne(@RequestBody RbacManager rbacManager){
        return rbacManagerService.addOne(rbacManager);
    }


    @PutMapping("/update")
    public ResponseEntity updateById(@RequestBody RbacManager rbacManager){

        System.out.println(rbacManager);
        return rbacManagerService.updateOne( rbacManager);
    }

}
